package com.tc.dispatch.aa.ejb;

import java.util.*;
import javax.ejb.*;
import com.tc.dispatch.aa.util.*;
import com.tc.dispatch.aa.model.*;
import com.tc.dispatch.aa.dao.*;
import com.tc.dispatch.aa.exception.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: ZJU</p>
 * @author DxFeng
 * @version 2.0
 */

public class AA_DPServiceBean implements SessionBean, ActionDAO, RelRuleDAO, RelUserRoleDAO, ResourceDAO, RoleDAO, UserDAO
{
    SessionContext sessionContext;

    //DAO object
    protected RoleDAO roleDAO = null;
    protected UserDAO userDAO = null;
    protected ResourceDAO resourceDAO = null;
    protected ActionDAO actionDAO = null;
    protected RelUserRoleDAO relUserRoleDAO = null;
    protected RelRuleDAO relRuleDAO = null;

    // Ejb required methods
    public void ejbRemove() { }
    public void ejbActivate() { }
    public void ejbPassivate() { }
    public void setSessionContext(SessionContext sessionContext) { this.sessionContext = sessionContext; }

    public void ejbCreate() throws CreateException {
        roleDAO = DAOFactory.getRoleDAO();
        userDAO = DAOFactory.getUserDAO();
        resourceDAO = DAOFactory.getResourceDAO();
        actionDAO = DAOFactory.getActionDAO();
        relUserRoleDAO = DAOFactory.getRelUserRoleDAO();
        relRuleDAO = DAOFactory.getRelRuleDAO();
    }


    public String createRole(AARoleValue role) throws AAException { return roleDAO.createRole(role); }
    public void removeRole(String role_id) throws AAException { roleDAO.removeRole(role_id); }
    public void updateRole(AARoleValue role) throws AAException { roleDAO.updateRole(role); }
    public AARoleValue getRole(String role_id) throws AAException { return roleDAO.getRole(role_id); }

    public String createUser(AAUserValue user) throws AAException { return userDAO.createUser(user); }
    public void removeUser(String user_id) throws AAException { userDAO.removeUser(user_id); }
    public void updateUser(AAUserValue user) throws AAException { userDAO.updateUser(user); }
    public AAUserValue getUser(String user_id) throws AAException { return userDAO.getUser(user_id); }
    public boolean checkUserIdAndPassword(String user_id, String password) throws AAException { return userDAO.checkUserIdAndPassword(user_id, password); }
    public String checkUsernameAndPassword(String username, String password) throws AAException { return userDAO.checkUsernameAndPassword(username,password); }

    public String createResource(AAResourceValue resource) throws AAException { return resourceDAO.createResource(resource); }
    public void removeResource(String resource_id) throws AAException { resourceDAO.removeResource(resource_id); }
    public void updateResource(AAResourceValue resource) throws AAException { resourceDAO.updateResource(resource); }
    public AAResourceValue getResource(String resource_id) throws AAException { return resourceDAO.getResource(resource_id); }
    public List findAllResourcePKs() throws AAException { return resourceDAO.findAllResourcePKs(); }

    public String createAction(AAActionValue action) throws AAException { return actionDAO.createAction(action); }
    public void removeAction(String action_id) throws AAException { actionDAO.removeAction(action_id); }
    public void updateAction(AAActionValue action) throws AAException { actionDAO.updateAction(action); }
    public AAActionValue getAction(String action_id) throws AAException { return actionDAO.getAction(action_id); }
    public List findAllActionPKs() throws AAException { return actionDAO.findAllActionPKs(); }

    public void setRelUserRole(String user_id, String role_id) throws AAException { relUserRoleDAO.setRelUserRole(user_id, role_id); }
    public void revokeRelUserRole(String user_id, String role_id) throws AAException { relUserRoleDAO.revokeRelUserRole(user_id, role_id); }
    public boolean isRelUserRoleExist(String user_id, String role_id) throws AAException { return relUserRoleDAO.isRelUserRoleExist(user_id, role_id); }
    public List findRolePKsByUser(String user_id) throws AAException { return this.relUserRoleDAO.findRolePKsByUser(user_id); }
    public List findUserPKsByRole(String role_id) throws AAException { return this.relUserRoleDAO.findUserPKsByRole(role_id); }

    public void setRelRule(String role_id, String resource_id, String action_id, int permission) throws AAException { relRuleDAO.setRelRule(role_id,resource_id,action_id,permission); }
    public void revokeRelRule(String role_id, String resource_id, String action_id) throws AAException { relRuleDAO.revokeRelRule(role_id, resource_id, action_id); }
    public boolean isRelRuleExist(String role_id, String resource_id, String action_id) throws AAException { return relRuleDAO.isRelRuleExist(role_id, resource_id, action_id); }
    public int getRelRule(String role_id, String resource_id, String action_id) throws AAException { return relRuleDAO.getRelRule(role_id, resource_id, action_id); }
    public boolean checkRolePermission(String role_id, String resource_id, String action_id) throws AAException { return relRuleDAO.checkRolePermission(role_id, resource_id, action_id); }
    public boolean checkUserPermission(String user_id, String resource_id, String action_id) throws AAException { return relRuleDAO.checkUserPermission(user_id, resource_id, action_id); }
    public List findAllRolePKs() throws AAException { return roleDAO.findAllRolePKs(); }
    public List findAllUserPKs() throws AAException { return userDAO.findAllUserPKs(); }

}


